// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import qs from 'qs'
import store from './store'
import VueCookies from 'vue-cookies'

import  './styles/index.scss'
import './router/each.js'

Vue.config.productionTip = false

Vue.prototype.$qs = qs
Vue.use(ElementUI)
Vue.use(VueCookies)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

/* 全局过滤器 */
import * as filters from './filters'
Object.keys(filters).forEach(key =>{
  Vue.filter(key, filters[key]);
})

/* 前置全局守卫 */
router.beforeEach((to, from, next) => {
  let title = to.meta.title;
  if(title) document.title = `RBAC权限管理系统 - ${title}`
  next()
})

/* 后置钩子 */
router.afterEach()
